/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-02-19 10:11:01
 * @LastEditTime : 2023-07-21 13:24:12
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\OrganizationGroup.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, DelDataButton } from '../Common/options'
import { OrganizationGroupList, ProjectList } from '../Common/Conversion'

export const OrganizationGroup = async ({ url, OptionsEvent, ClientData, Permission }) => {
    const { hostname } = window.location
    const projectUuid = await ProjectList()
    const code = await OrganizationGroupList()
    let data = {
        type: '系统设置',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === '9eee998a-40da-4a8f-b1c6-a56326d8d500') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增机构分组" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'code',
                title: '编码',
                valueType: 'select',
                valueEnum: code,
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
                order: 1,
            },
            { ...commonTableList.code, rules: true },
            { ...commonTableList.tableName, rules: true, order: 4 },
            {
                ...commonTableList.projectUuid,
                valueEnum: projectUuid,
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
                hideInSearch: !hostname.includes('jszx'),
                order: 3,
            },
            {
                dataIndex: 'organizationUuid',
                title: '组织机构',
                valueType: 'select',
                valueEnum: ClientData.organization,
                width: 200,
                multiple: true,
                rules: true,
                order: 2,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '8c731207-cacc-4bb2-92e4-b62d72bfa46e') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="delete"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
